package com.wqz.service.impl;

import com.wqz.dao.CommodityDao;
import com.wqz.pojo.Commodity;
import com.wqz.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class CommodityServiceImpl implements CommodityService {


    @Autowired
    private CommodityDao commodityDao;


    @Transactional
    @Override
    public List<Commodity> findCommodityList() throws Exception {
        //System.out.println("123123");
        //System.out.println("123123123:  "+commodityDao);
        //System.out.println("456456");
        List<Commodity> commodityList = commodityDao.findCommodityList();

        return commodityList;
    }
    @Transactional
    @Override
    public int deleteCommodity(Integer id) throws Exception {

        int res = commodityDao.deleteCommodity(id);
        return res;
    }

    @Transactional
    @Override
    public int addCommodity(Commodity commodity) throws Exception {
        int res = commodityDao.addCommodity(commodity);
        return res;
    }

    @Transactional
    @Override
    public Commodity findCommodityById(Integer id) throws Exception {
        return commodityDao.findCommodityById(id);
    }

    @Transactional
    @Override
    public List<Commodity> findSomeCommodity(String keyWord) throws Exception {

        List<Commodity> commodityList = commodityDao.findSomeCommodity(keyWord);
        return commodityList;
    }
}
